home *** CD-ROM | disk | FTP | other *** search
/ Windows News 2010 Summer - Disc 1 / WN_Ete2010_CD1.iso / Onglet5 / Weezo / Weezo setup.exe / {code_appDir} / www / res / explorer / music2 / mobileMusicDBView.php < prev    next >
PHP Script  |  2010-05-19  |  27KB  |  636 lines

  1. <?php
  2. /**
  3.  * iTunes-based music explorer
  4.  *
  5.  * Display an audio files explorer based on iTunes music database
  6.  * Audio files list
  7.  * Playlist functions
  8.  * Audio player (streaming)
  9.  *
  10.  * PHP version 5
  11.  *
  12.  * LICENSE: This source file is subject to version 3.0 of the PHP license
  13.  * that is available through the world-wide-web at the following URI:
  14.  * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
  15.  * the PHP License and are unable to obtain it through the web, please
  16.  * send a note to license@php.net so we can mail you a copy immediately.
  17.  *
  18.  * @category   NA
  19.  * @package    NA
  20.  * @author     Nicolas Bruley / Peer 2 World <contact@weezo.net>
  21.  * @copyright  2005-2009 Nicolas Bruley / Peer 2 World
  22.  * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
  23.  * @version    CVS: $Id:$
  24.  * @link       http://www.weezo.net
  25.  * @since      File available since Release 1.4
  26.  */
  27.  
  28.  
  29. /**
  30.  * @desc Init mobile specific data
  31.  *
  32.  */
  33. function mmDBInitResourceData(){
  34.     global $db;
  35.     if(cfRGetVar('mobileParametersLoaded')) return;
  36.  
  37.     // Number of artists / albums / playlists per page
  38.     cfRInitVar('itemsPerPage',20);
  39.  
  40.     // View
  41.     cfRSetVar('view','search');
  42.     if(sqlite_single_query("SELECT count(id) FROM tracks",$db,SQLITE_ASSOC)<=cfRGetVar('itemsPerPage')) cfRSetVar('view','files');
  43.  
  44.     // Done init
  45.     cfRSetVar('mobileParametersLoaded',1);
  46. }
  47.  
  48. /**
  49.  * @desc Top right explorer-specific controls
  50.  *
  51.  * @return string: HTML code
  52.  */
  53. function mmDBTopControls(){
  54.     $output='';
  55.     // View audio files button
  56.     $output.=mfButton(false,'javascript:setView(\'files\')',outIcon('fi/med/icoMusList'),'id="setViewFiles"',(cfRGetVar('view')=='files')?'on':'');
  57.  
  58.     // Search files button
  59.     $output.=mfButton(false,'javascript:setView(\'search\')',outIcon('fi/med/icoSearch'),'id="setViewSearch"',(cfRGetVar('view')=='search')?'on':'');
  60.  
  61.     // Tools (playlist/multiple downloads) button
  62.     if(cfBGetVar('playlistFormat'))
  63.         $output.=mfButton(false,'javascript:setView(\'tools\')',outIcon('fi/med/icoM3U'),'id="setViewTools"',(cfRGetVar('view')=='tools')?'on':'');
  64.  
  65.     return $output;
  66. }
  67.  
  68. /**
  69.  * @desc Insert scripts
  70.  *
  71.  */
  72. function mmDBInsertScripts(){
  73.     outInsertStandardComForm($_SERVER['PHP_SELF'],cfUTF8Encode(cfResourceRelativePath(cfRGetVar('efCurrentDirectory'))));
  74.     // Common explorer js functions
  75.     if(!cfBGetVar('inlineJS')) echo cfScriptLink('mExplorer.js');
  76. ?>
  77. <script type="text/javascript">
  78. <?php
  79. // Inline explorer scripts
  80. if(cfBGetVar('inlineJS')) echo file_get_contents(cfAppDocRoot().'/js/mExplorer.js');
  81. ?>
  82. var eV="<?php echo cfRGetVar('view'); ?>";
  83. <?php if(cfRGetVar('inlinePlayer')) echo 'var inlinePlayer=1;'; ?>
  84. var gAFT,gACT,gArFT,gArCT,tGT,gPCT,gATDCT,tDCT,tDCF,aDFT,aDCT,mDiv;
  85. function init(){
  86.     gAFT=tPrep("groupByAlbumFull");
  87.     gACT=tPrep("groupByAlbumCompact");
  88.     gArFT=tPrep("groupByArtistFull");
  89.     gArCT=tPrep("groupByArtistCompact");
  90.     tGT=tPrep("trackGroup");
  91.     gPCT=tPrep("groupByPlaylistCompact");
  92.     gATDCT=tPrep("albumTrackDetailCompact");
  93.     tDCT=tPrep("trackDetailCompact");
  94.     tDCF=tPrep("trackDetailFull");
  95.     aDFT=tPrep("albumDetailFull");
  96.     aDCT=tPrep("albumDetailCompact");
  97.  
  98.     mDiv=dgi("mainDiv")
  99.     if(eV=='files')    fas('','refreshDisplay');
  100. }
  101. function setViewIco(){
  102.     if(a=dgi('setViewSearch')) a.className=(eV=='search')?'btSel':'bt';
  103.     if(a=dgi('setViewFiles')) a.className=(eV=='files')?'btSel':'bt';
  104.     if(a=dgi('setViewTools')) a.className=(eV=='tools')?'btSel':'bt';
  105. }
  106. function setView(d,n,nS){
  107.     eV=d;
  108.     setViewIco();
  109.     if(n) mwl.liSel(n);
  110.     if(!nS) fas('','setView',d,'','async');
  111. }
  112.  
  113. <?php if(cfBGetVar('playlistFormat')) {
  114.     echo 'var supportsPlaylist=0;';
  115. }
  116. else echo 'var supportsPlaylist=1;'
  117. ?>
  118. var searchValue;
  119. var lPID="<?php echo cfRGetVar('Library Persistent ID');?>";
  120. var coverTemplate="<?php echo cfExtImage('*resourceBasePath*/IMAGEPATH',FULLVIEW_COVER_WIDTH,FULLVIEW_COVER_WIDTH,true,0,array('utf8Decode'=>true),true);?>";
  121. var coverSmallTemplate=coverTemplate;
  122. var hmsCaption="<?php echo cfCaptionJS('javascriptHourMinSecFormat');?>";
  123. var msCaption="<?php echo cfCaptionJS('javascriptMinSecFormat');?>";
  124.  
  125.  
  126. function fTime(secs){
  127.     if(!secs) return '-';
  128.     var h=Math.floor(secs/3600);
  129.     var m=Math.floor(Math.floor((secs%3600))/60);
  130.     var s=Math.floor(secs%60);
  131.     if(h>0 && m<10) m="0"+m;
  132.     if(s<10) s="0"+s;
  133.     if(h>0) return hmsCaption.replace(/%1/,h).replace(/%2/,m).replace(/%3/,s);
  134.     else return msCaption.replace(/%1/,m).replace(/%2/,s);
  135. }
  136.  
  137. function insertCover(t, img, small){
  138.     if(img.length>0){
  139.         <?php
  140.         if(SOURCE_TYPE=='iTunes') echo    't=t.replace(/COVERSRC/g,((small)?coverSmallTemplate:coverTemplate).replace(/IMAGEPATH/,img.replace(/#/,lPID)));';
  141.         else echo 't=t.replace(/COVERSRC/g,((small)?coverSmallTemplate:coverTemplate).replace(/IMAGEPATH/,img));';
  142.         ?>
  143.     }
  144.     else {
  145.         t=t.replace(/COVERSRC/g,'<?php echo dirname($_SERVER['PHP_SELF']);?>/cover.png');
  146.     }
  147.  
  148.     t=t.replace(/EXTRAHTML=""/i,'width="'+Math.floor(2*<?php echo FULLVIEW_COVER_WIDTH;?>/((small)?2:2))+'" height="'+Math.floor(2*<?php echo FULLVIEW_COVER_WIDTH;?>/((small)?2:2))+'"');
  149.     return t.replace(/imgtag/gi,'img');
  150. }
  151.  
  152. // PLAY FUNCTIONS
  153. function playTrack(trackId){fas(trackId,'view','firstLoad','','<?php if(cfRGetVar('inlinePlayer')) echo 'async'; else echo 'sync';?>')}
  154. function playAlbum(artistName, albumName){view('album/'+artistName+'/'+albumName,<?php echo DEFAULT_AUDIO_WINDOW_WIDTH.','.DEFAULT_AUDIO_WINDOW_HEIGHT;?>)}
  155. function playArtist(artistName){view('artist/'+artistName,<?php echo DEFAULT_AUDIO_WINDOW_WIDTH.','.DEFAULT_AUDIO_WINDOW_HEIGHT;?>)}
  156. function inlineSetSongPlayed(imgSrc,artist,album,title){
  157.     dgi('inlinePlayerImg').src=imgSrc;
  158.     dgi('inlineArtist').innerHTML=artist;
  159.     dgi('inlineAlbum').innerHTML=album;
  160.     dgi('inlineTitle').innerHTML=title;
  161. }
  162. function inlineUpdatePlayerInfo(trackId){fas(trackId,'inlineUpdatePlayerInfo');}
  163.  
  164. // PLAYLIST FUNCTIONS
  165. <?php if(cfBGetVar('playlistFormat')) {?>
  166. function plAddArtist(artistName){fas(artistName,'plAddArtist');}
  167. function plAddAlbum(artistName, albumName){fas(artistName,'plAddAlbum',albumName);}
  168. function plAddPlaylist(playlistId){fas(playlistId,'plAddPlaylist');}
  169. function plAddTrack(trackId){fas(trackId,'plAddTrack');}
  170. function plAddAllShuffle(){fas(0,'plAddAllShuffle');}
  171. <?php } ?>
  172.  
  173. // FILTER FUNCTIONS
  174. function changeDisplayType(ndt){fas(ndt,'changeDisplayType');}
  175. function changeItemsPerPage(nb){fas(nb,'changeItemsPerPage');}
  176. function changeOffset(selectSeq){fas(selectSeq,'changeOffset');}
  177. function groupBy(item){setTimeout("fas('"+item+"','changeGroupBy')",500)}
  178. function search(exp){
  179.     searchValue=exp;
  180.     fas(exp,'search');
  181. }
  182. function validateSearch(){}
  183. function toggleDetail(detailType, artistName, albumName, destId){
  184.     if(!n.innerHTML) showDetail(detailType, artistName, albumName, destId);
  185.     else n.innerHTML='';
  186. }
  187. var detArtN,detAlbN;
  188. function showDetail(detailType, artistName, albumName, destId){
  189.     var n=dgi("det"+destId);
  190.     if(n.innerHTML!='') return;
  191.     dgi("id"+destId).className='liSel';
  192.     detAlbN=D.comForm.data1.value=albumName;fas(detArtN=artistName,'showDetail', destId, detailType);
  193.     D.comForm.data1.value='*resSpecific*';
  194. }
  195. function updateDatabase(){fas(false,'updateDatabase',false,false,'sync');}
  196.  
  197. function plAddAlbumBt(art,alb,showAlb){<?php
  198.     if(cfBGetVar('playlistFormat')) {?>
  199.     return tPrep('plAddAlbumBt').replace(/ARTISTNAMEJS/g,art.replace(/'/g,"\\'")).replace(/ALBUMNAMEJS/g,alb.replace(/'/g,"\\'"))+liSep();
  200.     <?php } else echo 'return ""';?>
  201. }
  202.  
  203. // INSERT DETAIL VIEW FUNCTIONS
  204. function trackDetail(tD, tN, displayType){
  205.     var trackTemplate;
  206.     if(displayType=='compact') trackTemplate=tDCT; else trackTemplate=tDCF;
  207.     trackTemplate=trackTemplate.replace(/TRACKTIME/,fTime(tD[2])).replace(/TRACKNAME/g,tD[1]).replace(/TRACKID/g,tD[0]);
  208.     if(displayType=='full') trackTemplate=trackTemplate.replace(/ARTISTNAME/,tD[3]).replace(/ALBUMNAME/g,tD[4]);
  209.     if(tN) return trackTemplate.replace(/TRACKNUMBER/,'('+tN+') '); else return trackTemplate.replace(/TRACKNUMBER/,'');
  210. }
  211. function insertDetail(detailType, displayType, destId, data){
  212.     if(detailType=='Artist'){
  213.         var albumTemplate,i,o,album,html="",tracksHtml="",aH="",artistName=dgi("name"+destId).innerHTML;
  214.  
  215.         if(displayType=='displayFull') albumTemplate=aDFT; else albumTemplate=aDCT;
  216.         for(i=0;i<data.length;i++){
  217.  
  218.             album=data[i];
  219.             aH=albumTemplate.replace(/ITEMID/g,'destId'+i);
  220.             aH=aH.replace(/ALBUMNAMEJS/g,album[0].replace(/'/g,"\\'"));    // foo.replace(/'/g,"\\'"));
  221.             aH=aH.replace(/ALBUMNAME/g,album[0]);
  222.             aH=insertCover(aH,album[1],true);
  223.             aH=aH.replace(/YEAR/,album[2]);
  224.             aH=aH.replace(/TOTALTIME/,fTime(album[3]));
  225.             aH=aH.replace(/NBTRACKS/,album[4]);
  226.             aH=aH.replace(/ARTISTNAMEJS/g,artistName.replace(/'/g,"\\'"));    // foo.replace(/'/g,"\\'"));
  227.             aH=aH.replace(/ARTISTNAME/g,artistName);
  228.             tracksHtml=plAddAlbumBt(artistName,album[0])
  229.             tracksHtml='';
  230.             for(o=0;o<album[5].length;o++){tracksHtml+=trackDetail(album[5][o],o+1,'compact');}
  231.             html+=aH.replace(/TRACKS/,tracksHtml);
  232.         }
  233.     }
  234.     if(detailType=='Album'){
  235.         var html=plAddAlbumBt(detArtN,detAlbN,1);
  236.         for(var o=0;o<data.length;o++){html+=trackDetail(data[o],o+1,'compact');}
  237.         html=gATDCT.replace(/ITEMID/,'destId'+i).replace(/TRACKS/g,html);
  238.     }
  239.     if(detailType=='Playlist'){
  240.         var html="";
  241.         for(var o=0;o<data.length;o++){html+=trackDetail(data[o],o+1,'full');}
  242.         html=gATDCT.replace(/TRACKS/g,html);
  243.     }
  244.     dgi('mainDiv').innerHTML=html;
  245. }
  246.  
  247. function updateSelect(selectArray){
  248.     var html="";
  249.     var txt="";
  250.     for(var i=0;i<selectArray.length;i++){
  251.         html+='<option value="'+i+'"'+((selectArray[i].substr(0,1)=='S')?' selected':'')+'>'+selectArray[i].substr(1)+'</option>';
  252.     }
  253.     if(selectArray.length>0) return '<select size="1" class="textInput" style="width:100%" onChange="changeOffset(this.value)">'+html+'</select><br/>'; else return '';
  254. }
  255.  
  256. // FULL VIEW UPDATE FUNCTIONS
  257. function displayList(groupBy, displayType,  mixedFilter, dataArray, selectArray, currentOffset, replace){
  258.     var html='<table class="liTable" cellspacing=0 cellpadding=0><colgroup><col width="1%"><col width="98%"><col width="1%"></colgroup>';
  259.     var i;
  260.     
  261.     // Build list HTML
  262.     switch(groupBy){
  263.         case "artist":
  264.             for(i=0;i<dataArray.length;i++) html+=groupByArtist(mixedFilter,dataArray[i],i+currentOffset);
  265.             break;
  266.         case "album":
  267.             for(i=0;i<dataArray.length;i++) html+=groupByAlbum(mixedFilter,dataArray[i],i+currentOffset);
  268.             break;
  269.         case "playlist":
  270.             for(i=0;i<dataArray.length;i++) html+=groupByPlaylist(mixedFilter,dataArray[i],i+currentOffset);
  271.             break;
  272.         case "tracks":
  273.             for(i=0;i<dataArray.length;i++) html+=groupByTrack(mixedFilter,dataArray[i],i+currentOffset);
  274.         default:
  275.     }
  276.  
  277.     html+='</table>';
  278.     if(replace) mDiv.innerHTML=updateSelect(selectArray)+html;
  279.     else {
  280.         mDiv.innerHTML=((mDiv.innerHTML)?mDiv.innerHTML:updateSelect(selectArray))+html;
  281.     }
  282.     setView('files',0,1);
  283. }
  284. function displayNoResults(){mDiv.innerHTML=dgi("noSearchResult").innerHTML;}
  285.  
  286. function groupByArtist(displayType, item, index){
  287.     var t;
  288.     if(displayType=='artistFull') t=gArFT; else t=gArCT;
  289.     if(displayType=='artistFull') {
  290.         t=dgi("groupByArtistFull").innerHTML;
  291.     }
  292.     else t=dgi("groupByArtistCompact").innerHTML;
  293.     t=t.replace(/</g,"<").replace(/>/g,">");
  294.     t=t.replace(/ITEMID/g,"Artist"+index);
  295.     t=insertCover(t,item[3],false);
  296.     t=t.replace(/ARTISTNAMEJS/g,item[0].replace(/'/g,"\\'"));    //foo.replace(/'/g,"\\'"));
  297.     t=t.replace(/ARTISTNAME/g,item[0]);
  298.     t=t.replace(/NBTRACKS/,item[2]);
  299.     return t.replace(/NBALBUMS/,item[1]);
  300. }
  301. function groupByAlbum(displayType, item, index){
  302.     var t;
  303.     if(displayType=='albumFull') t=gAFT; else t=gACT;
  304.     t=t.replace(/ITEMID/g,"Album"+index);
  305.     t=insertCover(t,item[4],false);
  306.     t=t.replace(/ARTISTNAMEJS/g,item[1].replace(/'/g,"\\'"));    //foo.replace(/'/g,"\\'"));
  307.     t=t.replace(/ALBUMNAMEJS/g,item[0].replace(/'/g,"\\'"));    //foo.replace(/'/g,"\\'"));
  308.     t=t.replace(/ARTISTNAME/g,item[1]);
  309.     t=t.replace(/ALBUMNAME/g,item[0]);
  310.     t=t.replace(/TOTALTIME/,fTime(item[3]));
  311.     return t.replace(/NBTRACKS/,item[2]);
  312. }
  313. // "Array(Array('trackId','trackName','albumName','artistName','totalTime1),Array(),...)
  314. function groupByTrack(displayType, item, index){
  315.     var t=tGT.replace(/ITEMID/g,"Tracks"+index);
  316.     t=t.replace(/TRACKID/g,item[0]);
  317.     t=t.replace(/ARTISTNAMEJS/g,item[3].replace(/'/g,"\\'"));    // foo.replace(/'/g,"\\'"));
  318.     t=t.replace(/ALBUMNAMEJS/g,item[2].replace(/'/g,"\\'"));    // foo.replace(/'/g,"\\'"));
  319.     t=t.replace(/ARTISTNAME/g,item[3]);
  320.     t=t.replace(/ALBUMNAME/g,item[2]);
  321.     t=t.replace(/TRACKNAME/g,item[1]);
  322.     return t.replace(/TRACKTIME/,fTime(item[4]));
  323. }
  324. function groupByPlaylist(displayType, item, index){
  325.     var t=gPCT.replace(/ITEMID/g,"Playlist"+index);
  326.     t=t.replace(/PLAYLISTID/g,item[0]);
  327.     t=t.replace(/PLAYLISTNAME/g,item[1]);
  328.     return t.replace(/NBTRACKS/,item[2]);
  329. }
  330. function tPrep(i){return dgi(i).innerHTML.replace(/</g,"<").replace(/>/g,">")}
  331. </script>
  332. <?php
  333. }
  334.  
  335. /**
  336.  * @desc display Albums / Artist / Tracks templates HTML code
  337.  * @return void
  338.  *
  339.  */
  340. function mmDBDisplayTemplates(){
  341. ?>
  342. <div style="display:none">
  343. <?php //  GROUP BY ARTIST FULL ?>
  344. <!--        GROUP BY ARTIST FULL        -->
  345. <div id="groupByArtistFull">
  346. <tr class="li" id="idITEMID" onclick="showDetail('Artist','ARTISTNAMEJS','','ITEMID')">
  347. <td class="lil" style="vertical-align:top"><IMGTAG src="COVERSRC" EXTRAHTML="" class="frW"/></td>
  348. <td class="lic"><div class="lits" id="nameITEMID">ARTISTNAME</div><?php echo cfCaption('explorerAudioAlbum(s)','NBALBUMS');?><br/><?php echo cfCaption('explorerAudioTrack(s)','NBTRACKS');?>
  349. <div id="detITEMID"></div>
  350. </td>
  351. <td class="lir"><?php echo outImage(outIcon('go'));?></td>
  352. </tr>
  353. </div>
  354. <?php // GROUP BY ARTIST COMPACT  ?>
  355. <!--        GROUP BY ARTIST COMPACT        -->
  356. <div id="groupByArtistCompact">
  357. <tr class="li" id="idITEMID" onclick="showDetail('Artist','ARTISTNAMEJS','','ITEMID')">
  358. <?php 
  359.     if(cfBGetVar('playlistFormat')) {
  360.         echo '<td class="lil" onclick="mwl.liBlink(this);plAddArtist(\'ARTISTNAMEJS\')">';
  361.         echo outImage(outIcon('addMult'),false,'class="nfrLi32"');
  362.     } 
  363.     else echo '<td class="lil"> ';
  364. ?></td>
  365. <td class="lic"><div class="lits" id="nameITEMID">ARTISTNAME</div><?php echo cfCaption('explorerAudioAlbum(s)','NBALBUMS');?><br/><?php echo cfCaption('explorerAudioTrack(s)','NBTRACKS');?>
  366.  
  367. <div id="detITEMID"></div>
  368. </td>
  369. <td class="lir"><?php echo outImage(outIcon('go'));?></td>
  370. </tr>
  371. </div>
  372.  
  373. <?php //  GROUP BY ALBUM FULL ?>
  374. <!--        GROUP BY ALBUM FULL            -->
  375. <div id="groupByAlbumFull">
  376. <tr class="li" id="idITEMID" onclick="showDetail('Album','ARTISTNAMEJS','ALBUMNAMEJS','ITEMID')">
  377. <td class="lil" style="vertical-align:top"><IMGTAG src="COVERSRC" EXTRAHTML="" class="frW"/></td>
  378.  
  379. <td class="lic"><div class="lits" id="nameITEMID">ALBUMNAME</div>
  380. ARTISTNAME<br/>
  381. <?php echo cfCaption('explorerAudioTrack(s)','NBTRACKS');?><br/>
  382. <?php echo cfCaption('explorerAudioTotalTime').cfCaption('genSeparator');?>TOTALTIME
  383. <div id="detITEMID"></div>
  384. </td>
  385. <td class="lir"><?php echo outImage(outIcon('go'));?></td>
  386. </tr>
  387. </div>
  388.  
  389. <?php // GROUP BY ALBUM COMPACT  ?>
  390. <div id="groupByAlbumCompact">
  391. <tr class="li" id="idITEMID" onclick="showDetail('Album','ARTISTNAMEJS','ALBUMNAMEJS','ITEMID')">
  392. <td class="lil" style="vertical-align:top"> </td>
  393. <td class="lic"><div class="lits" id="nameITEMID">ALBUMNAME</div>
  394. ARTISTNAME<br/>
  395. <?php echo cfCaption('explorerAudioTrack(s)','NBTRACKS');?><br/>
  396. <?php echo cfCaption('explorerAudioTotalTime').cfCaption('genSeparator');?>TOTALTIME
  397. <div id="detITEMID"></div>
  398. </td>
  399. <td class="lir"><?php echo outImage(outIcon('go'));?></td>
  400. </tr>
  401. </div>
  402. <?php // GROUP BY PLAYLIST COMPACT  ?>
  403. <div id="groupByPlaylistCompact">
  404.     <tr class="li" id="idITEMID" onclick="showDetail('Playlist','PLAYLISTID','','ITEMID')">
  405.     <td class="lil" style="vertical-align:top"> </td>
  406.     <td class="lic"><div class="lits" id="nameITEMID">PLAYLISTNAME</div>
  407.     <?php echo cfCaption('explorerAudioTrack(s)','NBTRACKS');?><br/>
  408.     <?php echo cfCaption('explorerAudioTotalTime').cfCaption('genSeparator');?>TOTALTIME
  409.     <div id="detITEMID"></div>
  410.     </td>
  411.     <td class="lir"><?php echo outImage(outIcon('go'));?></td>
  412.     </tr>
  413. </div>
  414. <?php // ALBUM DETAIL FULL  ?>
  415. <div id="albumDetailFull">
  416. <div id="albumITEMID" class="frame3">
  417. <table class="li" cellspacing="0"><colgroup><col width="1%"><col width="98%"><col width="1%"></colgroup>
  418. <tr class="li" id="idITEMID"<?php if(cfBGetVar('playlistFormat')){?> onclick="mwl.liBlink(this);plAddAlbum('ARTISTNAMEJS','ALBUMNAMEJS')"<?php }?>>
  419. <td class="lil"><IMGTAG src="COVERSRC" EXTRAHTML="" class="frW"/></td>
  420. <td class="lic"><div class="lits">ALBUMNAME</div>
  421. <?php
  422. echo cfCaption('explorerAudioTotalTime').cfCaption('genSeparator');?>TOTALTIME - <?php echo cfCaption('explorerAudioTrack(s)','NBTRACKS');
  423. if(cfBGetVar('playlistFormat')) echo '<br>'.cfCaption('explorerAudioPlaylistAdd');?></td>
  424. <td class="lir"><?php if(cfBGetVar('playlistFormat')) echo outImage(outIcon('addMult')); else echo ' ';?></td>
  425. </tr>
  426. <?php echo str_replace('<','<',mfListSpacer());?>
  427. TRACKS
  428. </table>
  429. <br/>
  430. </div>
  431.  
  432. <?php // ALBUM DETAIL COMPACT  ?>
  433. <div id="albumDetailCompact">
  434. <div id="albumITEMID" class="frame3">
  435. <table class="li" cellspacing="0"><colgroup><col width="1%"><col width="98%"><col width="1%"></colgroup>
  436. <tr class="li" id="idITEMID"<?php if(cfBGetVar('playlistFormat')){?> onclick="mwl.liBlink(this);plAddAlbum('ARTISTNAMEJS','ALBUMNAMEJS')"<?php }?>>
  437. <td class="lil" colspan="2"><div class="lits">ALBUMNAME</div>
  438. <?php
  439. echo cfCaption('explorerAudioTotalTime').cfCaption('genSeparator');?>TOTALTIME - <?php echo cfCaption('explorerAudioTrack(s)','NBTRACKS');
  440. if(cfBGetVar('playlistFormat')) echo '<br>'.cfCaption('explorerAudioPlaylistAdd');?></td>
  441. <td class="lir"><?php if(cfBGetVar('playlistFormat')) echo outImage(outIcon('addMult')); else echo ' ';?></td>
  442. </tr>
  443. <?php echo str_replace('<','<',mfListSpacer());?>
  444. TRACKS
  445. </table>
  446. <br/>
  447. </div>
  448.  
  449. <?php // ALBUM'S TRACKS DETAIL COMPACT  ?>
  450. <div id="albumTrackDetailCompact">
  451.     <br/><div id="tracksITEMID" class="frame3">
  452.     <table class="li" cellspacing="0"><colgroup><col width="1%"><col width="98%"><col width="1%"></colgroup>TRACKS</table>
  453.     </div>
  454. </div>
  455.  
  456. <?php // GROUP BY TRACK  ?>
  457. <div id="trackGroup">
  458.     <tr class="li" id="trackITEMID">
  459. <?php
  460.     if(cfBGetVar('playlistFormat')) {
  461.         echo '<td class="lil" onclick="mwl.liBlink(this);plAddTrack(\'TRACKID\')">'.str_replace('<','<',outImage(outIcon('add'),false,'class="nfrLi32"')).'</td><td class="lic"';
  462.     }
  463.     else echo '<td class="lil" colspan="2"';
  464. ?> onclick="playTrack('TRACKID')"><div class="lits">ARTISTNAME</div>TRACKNAME - TRACKTIME</td>
  465.     <td class="lir" onclick="playTrack('TRACKID')"><?php echo str_replace('<','<',outImage(outIcon('play'),false,'class="nfrLi32"'));?></td>
  466.     </tr>
  467. </div>
  468.  
  469. <?php //  FULL TRACK DETAIL ?>
  470. <div id="trackDetailFull">
  471.     <tr class="li">
  472.     <td class="lil">
  473.     <?php if(cfBGetVar('playlistFormat')) echo mfButton('','javascript:plAddTrack(\'TRACKID\')',outIcon('add'));?>
  474.     <?php if(cfRGetVar('downloadShortcut')) echo mfButton('','javascript:dl(\'TRACKID.mp3\')',outIcon('dl'));?></td>
  475.     <td class="lic" onclick="playTrack('TRACKID')"><div class="lits">TRACKNUMBER - TRACKNAME</div>TRACKTIME</td>
  476.     <td class="lir"><?php echo mfButton('','javascript:playTrack(\'TRACKID\')',outIcon('play'));?></td>
  477.     </tr>
  478. </div>
  479.  
  480.  
  481. <?php // TRACK DETAIL  ?>
  482. <div id="trackDetailCompact">
  483.     <tr class="li">
  484.     <td class="lil">
  485.     <?php if(cfBGetVar('playlistFormat')) echo mfButton('','javascript:plAddTrack(\'TRACKID\')',outIcon('add'));?>
  486.     <?php if(cfRGetVar('downloadShortcut')) echo mfButton('','javascript:dl(\'TRACKID.mp3\')',outIcon('dl'));?></td>
  487.     <td class="lic" onclick="playTrack('TRACKID')"><div class="lits">TRACKNUMBER - TRACKNAME</div>TRACKTIME</td>
  488.     <td class="lir"><?php echo mfButton('','javascript:playTrack(\'TRACKID\')',outIcon('play'));?></td>
  489.     </tr>
  490. </div>
  491.  
  492. <?php // Add album to playlist button  ?>
  493. <div id="plAddAlbumBt">
  494.     <tr class="li" onclick="mwl.liBlink(this);plAddAlbum('ARTISTNAMEJS','ALBUMNAMEJS')">
  495.     <td class="lil"><img src="<?php echo outIcon('addMult')?>"></td>
  496.     <td class="lic"><div class="lits">ALBUMNAMEJS</div><?php echo cfCaption('explorerAudioPlaylistAdd');?></td>
  497.     <td class="lir"> </td>
  498.     </tr>
  499. </div>
  500.  
  501. <?php // NO RESULT FOUND ?>
  502. <div id="noSearchResult">
  503.     <
  504. </div>
  505.  
  506. </div>
  507. <?php
  508. }
  509.  
  510. /**
  511.  * @desc display filter area HTML code
  512.  * @return void
  513.  *
  514.  */
  515. function mmDBDisplayFilter(){
  516.     global $itemsPerPageList;
  517.  
  518.     $output=mfListTable();
  519.  
  520.     // Database update
  521.     if(cfRGetVar('databaseUpdateMethod')=='manual')
  522.         $output.=mfListItem('onclick="updateDatabase()"',outImage(outIcon('change'),false,'class="frLi2"'),false,'<span class="lit">'.cfCaption('genDataUpdate').'</span>');
  523.  
  524.  
  525.     /**
  526.      * Group by
  527.      */
  528.  
  529.     $output.=mfListSpacer(cfCaption('genGroupBy'));
  530.     // Group by artist
  531.     $output.=mfListItem('name="selGroup" '.((0&&cfRGetVar('groupBy')=='Artist')?' class="liSel"':'').' onclick="mwl.liGrSel(this);groupBy(\'Artist\')"',outImage(outIcon('user'),false,'class="frLi2"'),false,'<span class="lit">'.cfCaption('explorerAudioArtist').'</span>',false,'<img src="/themes/mobile/go.gif">');
  532.  
  533.     // Group by album
  534.     $output.=mfListItem('name="selGroup" '.((0&&cfRGetVar('groupBy')=='Album')?' class="liSel"':'').' onclick="mwl.liGrSel(this);groupBy(\'Album\')"',outImage(outIcon('medCover'),false,'class="frLi2"'),false,'<span class="lit">'.cfCaption('explorerAudioAlbum').'</span>',false,'<img src="/themes/mobile/go.gif">');
  535.  
  536.     // Group by playlist
  537.     $output.=mfListItem('name="selGroup" '.((0&&cfRGetVar('groupBy')=='Playlist')?' class="liSel"':'').' onclick="mwl.liGrSel(this);groupBy(\'Playlist\')"',outImage(outIcon('fi/med/icoM3U'),false,'class="frLi2"'),false,'<span class="lit">'.cfCaption('explorerAudioPlaylist').'</span>',false,'<img src="/themes/mobile/go.gif">');
  538.  
  539.     /**
  540.      * Search
  541.      */
  542.     $output.=mfListSpacer(cfCaption('genSearch'));
  543.     $textInput='<input class="textInput lit" cols="1" id="searchInput" autocorrect="off" autocapitalize="off" value="'.((cfRGetVar('groupBy')=='Search')?str_replace('%','',cfRGetVar('searchValue')):'').'" onchange="mwl.liGrSel(dgi(\'liSearch\'));search(this.value)">';
  544.     $output.=mfListItem('name="selGroup" id="liSearch" '.((cfRGetVar('groupBy')=='Search')?' class="liSel"':''),outImage(outIcon('search'),false,'class="frLi2"'),'onclick="mwl.liGrSel(dgi(\'liSearch\'));search(dgi(\'searchInput\').value)"',$textInput);
  545.  
  546.     /**
  547.      * Display options
  548.      */
  549.  
  550.     // Items per page
  551.     $output.=mfListSpacer(cfCaption('explorerItemsPerPage'));
  552.     foreach ($itemsPerPageList as $value){
  553.         $output.=mfListItem((($value==cfRGetVar('itemsPerPage'))?'class="liSel" ':'').'name="ippGroup" onclick="mwl.liGrSel(this);changeItemsPerPage(\''.$value.'\')"',
  554.         outImage(outIcon('go'),false,'class="frLi2"'),false,
  555.         '<span class="lit">'.(($value==0)?cfCaption('genAll').' ':$value).'</span>',false);
  556.     }
  557.  
  558.     // Compact / Full display
  559.     $output.=mfListSpacer(cfCaption('genDisplay'));
  560.  
  561.     $output.=mfListItem('name="dGroup" '.((cfRGetVar('displayType')!=='displayCompact')?' class="liSel"':'').' onclick="mwl.liGrSel(this);changeDisplayType(\'displayFull\')"',outImage(outIcon('displayFull'),false,'class="frLi2"'),false,'<span class="lit">'.cfCaption('activityLogDetailDet').'</span>',false,' ');
  562.     $output.=mfListItem('name="dGroup" '.((cfRGetVar('displayType')=='displayCompact')?' class="liSel"':'').' onclick="mwl.liGrSel(this);changeDisplayType(\'displayCompact\')"',outImage(outIcon('displayList'),false,'class="frLi2"'),false,'<span class="lit">'.cfCaption('activityLogDetailInf').'</span>',false,' ');
  563.  
  564.  
  565.     return $output.'</table>';
  566. }
  567.  
  568.  
  569. // Initialize mobile specific data
  570. mmDBInitResourceData();
  571.  
  572. require_once(INCLUDE_DIR.'mobileFunctions.php');
  573.  
  574. $itemsPerPageList=array('0','10','20','50','100');
  575.  
  576. /*
  577.  ***************************************************************************************************************************
  578.  * Insert HEAD, JS functions and form
  579.  ***************************************************************************************************************************
  580.  */
  581. mfInsertHead(array('topControlsExtra'=>mmDBTopControls(),'bodyExtraHTML'=>'onload="init()"'));
  582.  
  583. // Scripts
  584. if(!cfIsAsync()) mmDBInsertScripts();
  585.  
  586. // Album/artists/playlists templates
  587. if(!cfIsAsync()) mmDBDisplayTemplates();
  588.  
  589. // Album/artists/playlists templates
  590. if(!cfIsAsync() && cfRGetVar('inlinePlayer')) {
  591.     require_once('viewFunctions.php');
  592.     echo '<div id="playerDiv" style="text-align:center">'.vfInsertAudioPlayer('','normal',false,'100%',30).'</div>';
  593. }
  594.  
  595. /**
  596.  * Tools (playlist / multiple downloads)
  597.  */
  598. if(cfRGetVar('view')=='tools'){
  599.     require_once(INCLUDE_DIR.'mobileExplorerFunctions.php');
  600.     mefDisplayTools(array('noMAddAll'=>1));
  601. }
  602.  
  603. /**
  604.  * Tools (playlist / multiple downloads)
  605.  */
  606. elseif(cfRGetVar('view')=='files'){
  607.     // If view changed to files, simulate a display update
  608.     if(isset($_POST['data3']) && $_POST['data3']=='setView') {
  609.         $_POST['data3']='refreshDisplay';
  610.         mDBprocessPost();
  611.         exit;
  612.     }
  613.     $output='<div class="frame2" style="line-height:10em;text-align:center;vertical-align:middle"><br/>'.outImage(outIcon('loading')).'<br/></div>';
  614.     if(cfIsAsync()) {
  615.         echo cfAsyncXMLInnerHTMLbyId($output,'mainDiv');
  616.         echo(cfAsyncFooter());
  617.     }
  618.     else echo('<div id="mainDiv">'.$output.'</div></body></html>');
  619. }
  620.  
  621.  
  622. /*
  623.  ***************************************************************************************************************************
  624.  * FILTER AREA
  625.  ***************************************************************************************************************************
  626.  */
  627. else{
  628.     $output=mmDBDisplayFilter(true);
  629.     if(cfIsAsync()) {
  630.         echo cfAsyncXMLInnerHTMLbyId($output,'mainDiv');
  631.         echo cfAsyncFooter();
  632.     }
  633.     else echo('<div id="mainDiv">'.$output.'</div></body></html>');
  634. }
  635. @sqlite_close($db);
  636. exit;